package com.tangmu.rabbits.ui.activity.mine;


import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.tangmu.rabbits.R;
import com.tangmu.rabbits.adapter.mine.IntegralDetailsAdapter;
import com.tangmu.rabbits.base.BaseActivity;
import com.tangmu.rabbits.constants.Constants;
import com.tangmu.rabbits.widget.ListDividerDecoration;
import com.tangmu.rabbits.widget.calendar.ZWCalendarView;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import butterknife.BindView;

public class SignInActivity extends BaseActivity {

    @BindView(R.id.calendarView)
    ZWCalendarView zwCalendarView;
    @BindView(R.id.tv_calendar_show)
    TextView tvShow;
    //
    @BindView(R.id.integral_recycler)
    RecyclerView mRecyclerView;
    private IntegralDetailsAdapter adapter;
    private List<Integer> datas = new ArrayList<>();

    @Override
    protected void initImmersionBar() {
        super.initImmersionBar();
        mImmersionBar.statusBarColor(R.color.transparent).titleBar(R.id.headerView).init();
    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_sign_in;
    }

    @Override
    public void initPresenter() {

    }

    @Override
    public void initView() {
        setHeaderImage(Constants.Position.LEFT, R.drawable.icon_back, false, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        setHeaderTitle("今日签到");

        zwCalendarView.setSelectListener(new ZWCalendarView.SelectListener() {
            @Override
            public void change(int year, int month) {
                tvShow.setText(String.format("%s 年 %s 月", year, month));
            }

            @Override
            public void select(int year, int month, int day, int week) {
                Toast.makeText(getApplicationContext(),
                        String.format("%s 年 %s 月 %s日，周%s", year, month, day, week),
                        Toast.LENGTH_SHORT).show();
            }
        });

        HashMap<String, Boolean> sign = new HashMap<>();

        sign.put("2018-05-02", true);
        sign.put("2018-05-03", true);

        sign.put("2018-04-01", true);
        sign.put("2017-07-23", true);
        sign.put("2017-07-24", false);
        sign.put("2017-07-25", true);
        sign.put("2017-08-12", false);
        sign.put("2017-08-13", true);
        sign.put("2017-08-14", true);
        sign.put("2017-08-15", false);
        sign.put("2017-08-18", false);
        sign.put("2017-08-31", true);
        sign.put("2017-09-05", true);
        sign.put("2017-09-07", false);
        sign.put("2017-09-08", false);
        sign.put("2017-09-09", true);
        sign.put("2017-10-09", true);
        zwCalendarView.setSignRecords(sign);

        //
        for (int i = 0; i < 10; i++) {
            datas.add(i);
        }
        mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext));
        mRecyclerView.setNestedScrollingEnabled(false);
        mRecyclerView.setFocusableInTouchMode(false);
        mRecyclerView.requestFocus();
        mRecyclerView.addItemDecoration(new ListDividerDecoration(mContext, R.color.line_e_color, 1));
        adapter = new IntegralDetailsAdapter(mContext, datas);
        mRecyclerView.setAdapter(adapter);
    }
}
